/**
将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的
输入：l1 = [1,2,4], l2 = [1,3,4]
输出：[1,1,2,3,4,4]
 */
function mergeTwoLists(l1, l2) {
  let head = new ListNode(0)
  let res = head
  while(l1&&l2) {
    if(l1.val<=l2.val) {
      res.next = l1
      l1 = l1.next
    }else {
      res.next = l2
      l2 = l2.next
    }
    res = res.next
  }
  res.next = l1 || l2
  return head.next
}